using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class ARdetailMap : EntityTypeConfiguration<ARdetail>
    {
        public ARdetailMap()
        {
            // Primary Key
            this.HasKey(t => new { t.id, t.SYMBOL, t.type, t.acct, t.DESC, t.reference, t.date });

            // Properties
            this.Property(t => t.id)
                .IsRequired()
                .HasMaxLength(6);

            this.Property(t => t.Company)
                .HasMaxLength(110);

            this.Property(t => t.SYMBOL)
                .IsRequired()
                .HasMaxLength(5);

            this.Property(t => t.type)
                .IsRequired()
                .HasMaxLength(2);

            this.Property(t => t.acct)
                .IsRequired()
                .HasMaxLength(40);

            this.Property(t => t.DESC)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.invno)
                .HasMaxLength(8);

            this.Property(t => t.batch)
                .HasMaxLength(8);

            this.Property(t => t.reference)
                .IsRequired()
                .HasMaxLength(6);

            // Table & Column Mappings
            this.ToTable("ARdetail");
            this.Property(t => t.id).HasColumnName("id");
            this.Property(t => t.Company).HasColumnName("Company");
            this.Property(t => t.SYMBOL).HasColumnName("SYMBOL");
            this.Property(t => t.type).HasColumnName("type");
            this.Property(t => t.acct).HasColumnName("acct");
            this.Property(t => t.DESC).HasColumnName("DESC");
            this.Property(t => t.invno).HasColumnName("invno");
            this.Property(t => t.batch).HasColumnName("batch");
            this.Property(t => t.reference).HasColumnName("reference");
            this.Property(t => t.date).HasColumnName("date");
            this.Property(t => t.duedate).HasColumnName("duedate");
            this.Property(t => t.amtpat).HasColumnName("amtpat");
            this.Property(t => t.amt).HasColumnName("amt");
            this.Property(t => t.amtDOL).HasColumnName("amtDOL");
        }
    }
}
